<?php
declare(strict_types=1);
namespace App\Service\Community\Follower;
use Auth;
class FollowerUpdate implements FollowerUpdateInterface {
    public function follow($user_ids):bool{
        if (!is_array($user_ids)) {
            $user_ids = compact('user_ids');
        }
        Auth::user()->followings()->sync($user_ids, false);
        return true;
    }
    public function unfollow($user_ids):bool{
        if (!is_array($user_ids)) {
            $user_ids = compact('user_ids');
        }
        Auth::user()->followings()->detach($user_ids);
        return true;
    }
    public function store($user):bool{
        if (!Auth::user()->isFollowing($user->id)) {
            FollowerUpdate::follow($user->id);
        }
        return true;
    }
    public function destroy($user):bool{
        if (Auth::user()->isFollowing($user->id)) {
            FollowerUpdate::unfollow($user->id);
        }
        return true;
    }
}
